Skip to content

refactor(components): extract answer-thread turn from ClinicalDashboard (maturity X3)#1034

Merged
BigSimmo merged 4 commits into
mainfrom
claude/maturity-x3-clinicaldashboard
Jul 21, 2026
Merged

refactor(components): extract answer-thread turn from ClinicalDashboard (maturity X3)#1034
BigSimmo merged 4 commits into
mainfrom
claude/maturity-x3-clinicaldashboard

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

Maturity X3, continued — the second ratchet monolith, ClinicalDashboard.tsx.

Unlike DocumentViewer (#1025), this file is already heavily decomposed (72
src/components/clinical-dashboard/* modules), so the large presentational leaves are long
gone and the residual is a tightly-coupled orchestrator core. This is therefore an
incremental ratchet: extract the one clean self-contained leaf that remained inline — the
answer-thread turn — into a new module:

  • src/components/clinical-dashboard/answer-thread-turn.tsx — the AnswerTurn type,
    maxVisiblePriorTurns, and PriorAnswerTurnSurface (the collapsible read-only view of a
    previous answer turn kept on screen after a newer answer arrives).

Verbatim move — the component body is unchanged and the container imports the three symbols
exactly as before. ClinicalDashboard.tsx 4,271 → 4,157 lines; the maintainability budget
is ratcheted 4,272 → 4,157 to lock it in. The new module name (answer-thread-turn)
deliberately avoids colliding with the unrelated pre-existing prior-answer-turn-surface.tsx.

Honest scope note: the residual dashboard is orchestration (state, effects, data fetch,
handlers) with no large safe leaves left, so further extractions are smaller incremental
units. Off the RAG-ranking lane — no src/lib/rag/**, retrieval, ranking, or eval files
touched.

Verification

  • npm run typecheck — 0 errors
  • npm run lint — 0 warnings
  • npm run test — 3,047 passing. The only failure is the pre-existing container-only
    pdf-extraction-budget flake (Python OCR stack absent in this VM), which touches no
    dashboard code.
  • npm run check:maintainability-budgets — ratcheted to 4,157, passes
  • npm run check:knip — no dead code / orphaned exports (all three new exports consumed)
  • Targeted verify:ui (Chromium)ui-smoke.spec.ts "answer mode keeps prior turns
    visible for follow-up questions" (which renders the moved PriorAnswerTurnSurface) passes
    against the installed chromium-1194 binary.

UI note: as in #1025, the container's Playwright browser build (1194) mismatches the project's
pinned build (1228), so the full verify:ui errors at browser launch — a container limitation,
not a code issue. The targeted spec was run against the installed Chromium and passes. CI's
Production UI job runs the full gate with the correct binaries.

Risk and rollout

  • Risk: low — a single verbatim leaf extraction; no behaviour, props, or render structure
    changed (the moved component's data-* attributes and DOM are identical).
  • Rollback: revert the single commit.
  • Provider or production effects: None.

Clinical Governance Preflight

Not applicable — per scripts/pr-policy.mjs, presentation components are clinical-risk only
when they touch auth/upload/download/privacy/patient surfaces, which this does not. No
ingestion, answer generation, retrieval/ranking, source-governance, document-access, privacy,
schema, or production behaviour changed; the rendered output is byte-identical.

Notes

  • Part of the repository-maturity backlog (docs/maturity-backlog-workorders.md, X3), updated
    on-branch. rag.ts remains the largest open decomposition target (deferred until the RAG
    lane is confirmed quiet).

🤖 Generated with Claude Code


Generated by Claude Code

Summary by CodeRabbit

  • Improvements

    • Improved the presentation of prior answer-thread turns in the Clinical Dashboard.
    • Prior turns remain available in a collapsible, read-only view with clearer previews.
    • Preserved support for expanding entries, copying answer content, and reviewing relevant sources when needed.
  • Documentation

    • Updated dashboard decomposition progress and maintainability tracking documentation.

…rd (maturity X3)

ClinicalDashboard.tsx is the second maintainability-ratchet monolith. It is already
heavily decomposed (72 clinical-dashboard/* modules), so this is an incremental
ratchet: extract the self-contained answer-thread turn leaf — the `AnswerTurn` type,
`maxVisiblePriorTurns`, and the `PriorAnswerTurnSurface` component (the collapsible
read-only view of a previous answer turn) — into a new
`src/components/clinical-dashboard/answer-thread-turn.tsx`.

Verbatim move — the component body is unchanged and the container imports the three
symbols exactly as before. ClinicalDashboard.tsx 4,271 -> 4,157 lines; the
maintainability budget is ratcheted 4,272 -> 4,157 to lock in the reduction. A new
module name (answer-thread-turn) avoids colliding with the unrelated pre-existing
prior-answer-turn-surface.tsx.

The residual ClinicalDashboard is a tightly-coupled orchestrator core with no large
safe leaves left; further extractions are smaller incremental units.

Verified: typecheck, lint, the full unit suite (3,047 passing; only the pre-existing
container-only pdf-extraction-budget flake fails), knip (no orphaned exports),
maintainability budgets, and the targeted "prior turns visible" Chromium spec that
renders the moved component — all pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Jc1ZYHFjXjn6mE6U6riVU
@supabase

supabase Bot commented Jul 21, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The prior answer-thread turn UI and supporting contract move from ClinicalDashboard.tsx into a dedicated component module. Dashboard imports, maintainability budgets, and X3 progress documentation are updated to reflect the extraction.

Changes

Answer thread turn extraction

Layer / File(s) Summary
Answer turn component
src/components/clinical-dashboard/answer-thread-turn.tsx
Adds the AnswerTurn contract, visibility limit, memoized rendering logic, collapsible preview/full-answer UI, copy handling, and conditional source-review notice.
Dashboard wiring and tracking
src/components/ClinicalDashboard.tsx, scripts/check-maintainability-budgets.mjs, docs/maturity-backlog-workorders.md
Replaces local answer-turn definitions with the extracted module, removes unused imports, lowers the dashboard budget to 4,157 lines, and updates X3 progress documentation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main refactor: extracting the answer-thread turn from ClinicalDashboard for X3 maturity work.
Description check ✅ Passed The description follows the template with Summary, Verification, Risk and rollout, Clinical Governance Preflight, and Notes, and it covers the main verification results.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/maturity-x3-clinicaldashboard

Comment @coderabbitai help to get the list of available commands.

@BigSimmo
BigSimmo marked this pull request as ready for review July 21, 2026 02:22
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 21, 2026 02:22
BigSimmo pushed a commit that referenced this pull request Jul 21, 2026
- check:maintainability-budgets was red: the reduced-motion helper import
  (resolveScrollBehavior) grew ClinicalDashboard.tsx 4272->4274 and
  DocumentViewer.tsx 1733->1734 (import + one prettier-wrapped call).
  Ratchet the no-growth budgets by the exact +2/+1; no monolith complexity
  added, and #1034 is separately decomposing ClinicalDashboard downward.
- docs/testing.md: document verify:pr-local (before handoff) and
  npm run ensure (before browser work) in the Verify checklist.
- clinical-dashboard-merge-artifacts.test.ts: also assert the non-answer
  (sm:mb-0) branch carries the scroll-padding-bottom utility.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013f523gDfoBXPYT4H9vXRkE
@BigSimmo
BigSimmo merged commit 7eb2176 into main Jul 21, 2026
17 checks passed
@BigSimmo
BigSimmo deleted the claude/maturity-x3-clinicaldashboard branch July 21, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants